const syncService = require('../services/SyncService');

async function testSync() {
  try {
    console.log('开始测试同步功能...');
    
    // 测试同步单个包
    console.log('\n=== 测试同步单个包 ===');
    const testPackages = ['lodash', 'axios'];
    
    for (const packageName of testPackages) {
      try {
        console.log(`正在同步: ${packageName}`);
        const result = await syncService.syncPackage(packageName);
        console.log(`✓ 同步成功: ${packageName}`, {
          id: result.id,
          name: result.name,
          version: result.version,
          downloads: result.downloads
        });
      } catch (error) {
        console.error(`✗ 同步失败: ${packageName}`, error.message);
      }
    }
    
    console.log('\n测试完成！');
    
  } catch (error) {
    console.error('测试失败:', error);
  } finally {
    process.exit(0);
  }
}

testSync();